<%@page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib prefix="c" uri="/jstl-c-tags"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %> 
<%@page import="org.waddy.servlet.User"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	User user = (User) session.getAttribute("user");
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">
		<title>monitor</title>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="description" content="monitor">

		<script type="text/javascript" src="<%=basePath%>/dwr/engine.js"></script>
		<script type="text/javascript" src="<%=basePath%>/dwr/util.js"></script>
		<script type="text/javascript" src="<%=basePath%>/dwr/interface/ChatServer.js"></script>
		<script type="text/javascript" src="<%=basePath%>/js/jquery-1.3.1.min.js"></script>

		<script type="text/javascript" src="<%=basePath%>/js/chat.js"></script>
		<script type="text/javascript" src="<%=basePath%>/js/date.js"></script>

		<script type="text/javascript">
		//表示在刷新页面或关闭页面时调用服务端清除多余ScriptSession的方法.
		//一定要加上window.onbeforeunload事件,这样才能在IE中有效.
		   window.onbeforeunload=ChatServer.exitGame();
		   document.body.onunload=ChatServer.exitGame();
  		</script>
		<script>  
			function getData(){  
			    dwrPush.sendMessage(null);  
			}  
	          
			function receiveMessages(data) {  
				for(var key in data){
				 $('#tTotalInputNum_'+key).html(data[key].totalInputNum);
				 $('#tTotalProcessNum_'+key).html(data[key].totalProcessNum);
				 //$('#tLatestInputTime_'+key).html(new Date(data[key].latestInputTime).Format("yyyy/MM/dd hh:mm:ss"));
				 $('#tLatestInputTime_'+key).html(new Date(data[key].latestInputTime).Format("hh:mm:ss"));
				 $('#tLatestInputNum_'+key).html(data[key].latestInputNum);
				 $('#tLatestProcessTime_'+key).html(new Date(data[key].latestProcessTime).Format("hh:mm:ss"));
				 $('#tLatestProcessNum_'+key).html(data[key].latestProcessNum);
				 $('#tCurrNum_'+key).html(data[key].currNum);
				}
			}
		</script>
</head>

<body onload="dwr.engine.setActiveReverseAjax(true);ChatServer.send('0',' ','');">  
    <div align="center">
        <TABLE id="tableData" title="任务监控表" align="center" border="1">  
        <tr id="titleData">
        	<td colspan="9">任务运行监控表</td>
        	<td colspan="1" onclick="getData()" style="size: 10px"><a href="<c:url value='/monitorResult/monitor.htm?action=getMonitorRecord'/>">更多</a></td>
        </tr>  
        <TR id="headData" bgcolor="#fffce7" style="color:#968054">
            <TD>任务号</TD>
            <TD>任务名称</TD>
            <TD>启动时间</TD>
            <TD>累计输入数量</TD>
            <TD>累计处理数量</TD>
            <TD>上次输入时间</TD>
            <TD>上次输入数量</TD>
            <TD>上次处理时间</TD>
            <TD>上次处理数量</TD>
            <TD>当前队列数量</TD>
         </TR> 
         <!-- 此处for循环，生成各任务的运行时记录条目 -->
         <c:forEach items="${runtimeTable}" var="taskItem">
         <tr>
         	<td><span id="tNo_${taskItem.key}">${taskItem.value.taskId}</span></td>
         	<td><span id="tName_${taskItem.key}">${taskItem.value.taskName}</span></td>
         	<td>
	         	<span id="tStartTime_${taskItem.key}">
	         		<fmt:formatDate value="${taskItem.value.startTime}" pattern="yyyy/MM/dd HH:mm:ss" /> 
	         	</span>
         	</td>
         	<td><span id="tTotalInputNum_${taskItem.key}">${taskItem.value.totalInputNum}</span></td>
         	<td><span id="tTotalProcessNum_${taskItem.key}">${taskItem.value.totalProcessNum}</span></td>
         	<td>
	         	<span id="tLatestInputTime_${taskItem.key}">
	         	</span>
         	</td>
         	<td><span id="tLatestInputNum_${taskItem.key}">${taskItem.value.latestInputNum}</span></td>
         	<td>
         		<span id="tLatestProcessTime_${taskItem.key}">
         		</span>
         	</td>
         	<td><span id="tLatestProcessNum_${taskItem.key}">${taskItem.value.latestProcessNum}</span></td>
         	<td><span id="tCurrNum_${taskItem.key}">${taskItem.value.currNum}</span></td>
         </tr>
         </c:forEach>
        </TABLE>
    </DIV>      
 </body>  
 
</html> 